Ext.namespace('VAS');

VAS.ArticleContentPanel = function(config) {
	this.config = config;
    VAS.ArticleContentPanel.superclass.constructor.call(this,config);
}

Ext.extend(VAS.ArticleContentPanel,Ext.FormPanel, {
	
	
	initComponent : function() {
		var _this=this;
		
		var config={
			bodyStyle:'padding:5px 15px 0 ',
			width         : '100%',
            frame         : true,
            fileUpload    : true,
		    minButtonWidth: 50,
		    buttonAlign   : 'right',
		    height        : 500,
			labelAlign    : 'left',
            layout        : 'column',
            items         : [{
				layout      : 'column',
				columnWidth : 1,
				border      : false,
				items       : [{
					columnWidth : .33,
					layout      : 'form',
					border      : false,
					items       : [ {
							labelStyle      : "width:80px;text-align:left",
							id				: 'channelName',
							name            : 'channelName',
							xtype           : 'textfield',
							fieldLabel      : '所属栏目',
							disabled        : true
						}, 
						 {
							labelStyle      : "width:80px;text-align:left",
							xtype           : 'textfield',
							fieldLabel      : '来源',
							id              : 'origin',
							name            : 'origin',
							vtype           : 'MaxLen100'
						},
						{
							labelStyle      : "width:80px;text-align:left",
							xtype           : 'textfield',
							fieldLabel      : '视频代码',
							id              : 'videoCode',
							name            : 'videoCode',
							vtype           : 'MaxLen100'
						},
						{
							labelStyle      : "width:80px;text-align:left",
							xtype           : 'textfield',
							fieldLabel      : '高清URl地址',
							id              : 'hdUrl',
							name            : 'hdUrl',
							vtype           : 'webDomai'
						}

						]
				},{
					columnWidth : .33,
					layout : 'form',
					border : false,
					items : [ {
							labelStyle      : "width:80px;text-align:left; color:red",
							xtype           : 'textfield',
							fieldLabel      : '标题',
							id              : 'title',
							name            : 'title',
							allowBlank		: false,
							blankText       : "必填项",
							vtype           : 'MaxLenTitle200'
						}
						,{
					            xtype: 'radiogroup',
					            id     : "isCommend1",
					            fieldLabel : '是否推荐',
					            labelStyle  : "width:80px;text-align:left",
					            width   : 120,
					            height	: 22,
					              items: [
						                {boxLabel: '是', name: 'isCommend', inputValue:"1"},
						                {boxLabel: '否', name: 'isCommend', inputValue:"0",checked: true}
					              ]
						}
						,
 						{
							labelStyle      : "width:80px;text-align:left",
							xtype           : 'textfield',
							fieldLabel      : '产品代码',
							disabled        : true,
							id              : 'productCode',
							name            : 'productCode',
							vtype           : 'MaxLen100'
						}
						,{
								labelStyle      : "width:80px;text-align:left",
			                    xtype         : 'hidden',
								fieldLabel      : '关键字',
		                   		id            : 'keyword',
		                   		name          : 'keyword'
						}
						]
				}
				,{
					columnWidth : .33,
					layout : 'form',
					border : false,
					items : [ {
							labelStyle      : "width:80px;text-align:left",
							xtype           : 'textfield',
							fieldLabel      : '作者',
							id              : 'author',
							name            : 'author',
							vtype           : 'MaxLenTitle'
						},
						{
					            xtype: 'radiogroup',
					            id     : "authorizeState",
					            fieldLabel : '是否鉴权',
					            labelStyle  : "width:80px;text-align:left",
					            width   : 120,
					            height	: 22,
					              items: [
						                {boxLabel: '是', name: 'authorizeState', inputValue:"1"},
						                {boxLabel: '否', name: 'authorizeState', inputValue:"0",checked: true}
					              ]
						}
						,
						 {
							labelStyle      : "width:80px;text-align:left",
							xtype           : 'textfield',
							fieldLabel      : '标清URl地址',
							id              : 'sdUrl',
							name            : 'sdUrl',
							vtype           : 'webDomai'
						}
						, {
								id              : 'keywordDesc',
								xtype           : "hidden",
								hideLabel       : true,
								value           : '<font size=2 color=blue>关键字之间请以英文;隔开</font>'
							}
						]
				}
				
				]
			},
			
			{
				layout      : 'column',
				columnWidth : 1,
				border      : false,
				items       : [{
					columnWidth : .5,
					layout      : 'form',
					border      : false,
								items : [
									new Ext.form.ComboBox({
										store   : new Ext.data.Store({
												proxy     : new Ext.data.HttpProxy({url:'admin/article/ArticleAction!listhdTemplateList.action'+this.config.exParams}),
												reader    : new Ext.data.JsonReader({
													root  : 'data'
												}, [
													{name : 'id'},
													{name : 'name'}
												])							
										}),
							            fieldLabel    : '高清模板',
										name          : 'contentHDTemplate',
										id            : 'contentHDTemplate',
										mode          : 'remote',
										width         : 260,
										editable      : false,
										triggerAction : 'all',
										valueField    : 'id',
										displayField  : 'name'
									})	
								]
				},{
					columnWidth : .5,
					layout : 'form',
					border : false,
								items : [
									new Ext.form.ComboBox({
										store   : new Ext.data.Store({
												proxy     : new Ext.data.HttpProxy({url:'admin/article/ArticleAction!listsdTemplateList.action'+this.config.exParams}),
												reader    : new Ext.data.JsonReader({
													root  : 'data'
												}, [
													{name : 'id'},
													{name : 'name'}
												])							
										}),
							            fieldLabel    : '标清模板',
										name          : 'contentSDTemplate',
										id            : 'contentSDTemplate',
										mode          : 'remote',
										width         : 260,
										editable      : false,
										triggerAction : 'all',
										valueField    : 'id',
										displayField  : 'name'
									})	
								]
				}
				
				]
			}
			,
			{
					layout: "table",
					columnWidth : 1,
					items: [
						{
							xtype           : "panel",
							layout          : "form",
							width           : 105,
							items           : {xtype  : "label", fieldLabel: "标题图", labelStyle : "text-align:left"}
						}, {
			            	xtype           : 'fileuploadfield',
			            	buttonText      : '浏览...',
			            	width           : 300,
			            	id  			: "tiltePhoto",
			            	name			: "tiltePhoto"
						}, {
							id              : 'tiltePhotoDesc',
							xtype           : "label",
							hideLabel       : true
						}
						,{
							xtype           : 'hidden',
							id              : 'titleflag',
							name            : 'titleflag'
						}
						
					]
			},
			{
					layout: "table",
					columnWidth : 1,
					items: [
						{
							xtype           : "panel",
							layout          : "form",
							width           : 105,
							items           : {xtype: "label", fieldLabel: "内容图",	labelStyle:"text-align:left"}
						},{
		            		xtype           : 'fileuploadfield',
		            		buttonText      : '浏览...',
		            		width           : 300,
			            	id  			: "contentPhoto",
			            	name			: "contentPhoto"		            		
						}, {
							id              : 'contentPhotoDesc',
							xtype           : "label",
							hideLabel       : false
						}
						,{
							xtype           : 'hidden',
							id              : 'contentflag',
							name            : 'contentflag'
						}
					]
			},			
			{
					layout: "table",
					columnWidth : 1,
					items: [
						{
							xtype           : "panel",
							layout          : "form",
							width           : 105,
							items           : {xtype: "label", fieldLabel: "音频文件",	labelStyle:"text-align:left"}
						},{
		            		xtype           : 'fileuploadfield',
		            		buttonText      : '浏览...',
		            		width           : 300,
			            	id  			: "audio",
			            	name			: "audio"
		            	},{
							id              : 'audioDesc',
							xtype           : "label",
							hideLabel       : true
						}
						,{
							xtype           : 'hidden',
							id              : 'audioflag',
							name            : 'audioflag'
						}
					]
			}
			, 
			{
					layout         : "table",
					columnWidth    : 1,
					bodyStyle      : "margin:5px 0px 0px 0px",
					items: [
						{
							xtype          : "panel",
							layout         : "form",
							width          : 105,
							items          : {xtype: "label", fieldLabel: "内容",labelStyle:"text-align:left"}
						}, 			 
						 new Ext.TabPanel({
						 	id       : 'contentTab',
					        activeTab: 0,
					        width:720,
					        height:260,
					        plain:true,
					        items:[{
					        		id  : "panel_htmleditor",
					                title: 'HTML 编辑',
										items : [{
											xtype : 'htmleditor',
											width : 720,
											height : 233,
											id : 'content1',
											name : 'content1',
											defaultValue : '',
											plugins : [
													new Ext.ux.form.HtmlEditor.MidasCommand()
													,new Ext.ux.form.HtmlEditor.Divider()
//													,new Ext.ux.form.HtmlEditor.Word()
													,new Ext.ux.form.HtmlEditor.Table()
													,new Ext.ux.form.HtmlEditor.HR()
													,new Ext.ux.form.HtmlEditor.IndentOutdent()
													,new Ext.ux.form.HtmlEditor.SubSuperScript()
													,new Ext.ux.form.HtmlEditor.RemoveFormat()
												]
										}]
									
					            }
					            ,{
					            	id  : "panel_textarea",
					                title: '纯文本编辑',
					                items :[{
					                    xtype          : 'textarea',
					                    width          : 720,
					                    height         : 233,
				                   		id             : 'content2',
				                   		name           : 'content2'
									}]
					            }
					        ]
					    })
					]
			},			
			{
				xtype : 'hidden',
				name : 'id',				
				id : 'id'				
			},{
				xtype : 'hidden',
				name : 'content',				
				id : 'content'				
			}]
        };
		Ext.apply(this, config);
		Ext.apply(this.initialConfig, config);
		VAS.ArticleContentPanel.superclass.initComponent.apply(this, arguments);
	},
	
	checkForm : function() {
		/* 图片类型校验 */
		var imgType = "jpg|png|bmp|gif|jpeg";
		var tiltePhoto = Ext.getCmp("tiltePhoto");
		var contentPhoto = Ext.getCmp("contentPhoto");
		var audio = Ext.getCmp("audio");

		// 标题图
		if (tiltePhoto.getValue() != "") {
			var filetype = tiltePhoto.getValue().substring(
					tiltePhoto.getValue().lastIndexOf('.') + 1,
					tiltePhoto.getValue().length);
			if (imgType.indexOf(filetype.toLowerCase()) == -1) {
				Ext.Msg.alert("提示", "标题图只能上传图片类型文件！");
				tiltePhoto.setValue("");
				tiltePhoto.reset();
				return false;
			}
		}

		// 内容图
		if (contentPhoto.getValue() != "") {
			var filetype = contentPhoto.getValue().substring(
					contentPhoto.getValue().lastIndexOf('.') + 1,
					contentPhoto.getValue().length);
			if (imgType.indexOf(filetype.toLowerCase()) == -1) {
				Ext.Msg.alert("提示", "内容图只能上传图片类型文件！");
				contentPhoto.setValue("");
				contentPhoto.reset();
				return false;
			}
		}

		// 音频文件
		if (audio.getValue() != "") {
			var filetype = audio.getValue().substring(
					audio.getValue().lastIndexOf('.') + 1,
					audio.getValue().length);
			if ("mp3".indexOf(filetype.toLowerCase()) == -1) {
				Ext.Msg.alert("提示", "音频文件只能上传MP3文件！");
				audio.setValue("");
				audio.reset();
				return false;
			}
		}
		return true;
	}
	//加载审核数据
	
	,loadAuditForm:function(){
		this.load({
			
			    waitTitle   : '正在加载中...',
				waitMsg     : '正在向服务器发送请求', 
	 			url         : this.loadUrl,
	 			success     : function(form,action) {	

	 				if (action.result.data["authorizeState"] == 1) {
	 					Ext.getCmp("productCode").setDisabled(false);
	 				}
	 				
//	 				Ext.getCmp("tiltePhoto").setValue("");
	 				var tiltePhotoName = action.result.data["tiltePhotoName"];
	 				var tiltePhotoDesc = Ext.getCmp("tiltePhotoDesc");
	 				if (tiltePhotoName != "" && tiltePhotoName != "null"  && tiltePhotoName != undefined) {
	 					tiltePhotoDesc.setValue("<font size='2' color='red'><a href=javascript:exportFile('admin/article/ArticleAction!exportFile.action?id='+Ext.getCmp('id').getValue()+'&type=titlephoto')>"+tiltePhotoName+"</a>");
	 				}
	 				
//	 				Ext.getCmp("contentPhoto").setValue("");
	 				var contentPhotoName = action.result.data["contentPhotoName"];
	 				var contentPhotoDesc = Ext.getCmp("contentPhotoDesc");
	 				if (contentPhotoName != "" && contentPhotoName != "null"  && contentPhotoName != undefined) {
	 					contentPhotoDesc.setValue("<font size='2' color='red'><a href=javascript:exportFile('admin/article/ArticleAction!exportFile.action?id='+Ext.getCmp('id').getValue()+'&type=contentphoto')>"+contentPhotoName+"</a>");
	 				}
	 				
//	 				Ext.getCmp("audio").setValue("");
	 				var audioName = action.result.data["audioName"];
	 				var audioDesc = Ext.getCmp("audioDesc");
	 				if (audioName != "" && audioName != "null"  && audioName != undefined) {
	 					audioDesc.setValue("<font size='2' color='red'><a href=javascript:exportFile('admin/article/ArticleAction!exportFile.action?id='+Ext.getCmp('id').getValue()+'&type=audio')>"+audioName+"</a>");
	 				}
	 				
	 				var content = action.result.data["content"];
	 				var contentTab  = Ext.getCmp("contentTab");
	 				var pattern = /<\/?[^>]+>|&[^;]*;/gi;
	 				if (!pattern.test(content)) {
	 					contentTab.setActiveTab(1);
	 					Ext.getCmp("content2").setValue(content);
	 				} else {
	 					contentTab.setActiveTab(0);
	 					Ext.getCmp("content1").setValue(content);
	 				}
	 				
//	 				Ext.getCmp('idea').focus();
	 				
			 		Ext.getCmp("author").setReadOnly(true);
					Ext.getCmp("isCommend1").setReadOnly(true);
					Ext.getCmp("authorizeState").setReadOnly(true);
					Ext.getCmp("title").setReadOnly(true);
					Ext.getCmp("origin").setReadOnly(true);
					Ext.getCmp("videoCode").setReadOnly(true);
					Ext.getCmp("productCode").setReadOnly(true);
					Ext.getCmp("sdUrl").setReadOnly(true);
					Ext.getCmp("hdUrl").setReadOnly(true);
					Ext.getCmp("tiltePhoto").setReadOnly(true);
					Ext.getCmp("contentPhoto").setReadOnly(true);
					Ext.getCmp("audio").setReadOnly(true);
					Ext.getCmp("contentHDTemplate").setReadOnly(true);
					Ext.getCmp("contentSDTemplate").setReadOnly(true);
					Ext.getCmp("keyword").setReadOnly(true);
					Ext.getCmp("content1").setReadOnly(true);
					Ext.getCmp("content2").setReadOnly(true);
	 				
	 			},
	 			failure     : function(form,action) {
	 				Ext.Msg.alert("失败",action.result.msg);
	 			},  
	 			params      : {
	 				data    : Ext.util.JSON.encode(this.postData)
	 			}
	 	});			
		
	}

	
	

});


VAS.ArticleContentWindow = function($config) {
	var _this = this;
	_this.$config = $config
	var form  = new VAS.ArticleContentPanel({
		id        : "articleForm",
		url       : $config.formUrl,
		exParams  : _this.$config.exParams
	});
	var authorizeState = Ext.getCmp("authorizeState");
	var productCode = Ext.getCmp("productCode");
	authorizeState.on("change",function(radio,newValue,oldValue){
		if (newValue.getGroupValue() == 1) {
			productCode.setDisabled(false);
			productCode.allowBlank = false;
			productCode.blankText = "必填项",
			productCode.validate();	
		} else {
			productCode.setDisabled(true);
			productCode.allowBlank = true;
			productCode.validate();	
		}		
	});		
		
	var _form = form.getForm();

	var thisConfig = {
		autoScroll    : true,
		frame         : true,
		items         : form

	};
	if($config.actionType != 'articlepreview'){
		
		if($config.actionType == 'articleAdd'){
				Ext.apply(thisConfig,{
				buttons : [{	
		        	xtype   : 'submitbutton',
		        	text    : '保存',
		        	eventId : form.id,
		        	handler : function() {
		        		var channelName = Ext.getCmp('channelName');
		        		var tempChannelName = channelName.getValue();
						
		        		if (Ext.getCmp("contentTab").getActiveTab().id == "panel_htmleditor") {
							Ext.getCmp("content").setValue(Ext.getCmp("content1").getValue());            			
		        		} else {
							Ext.getCmp("content").setValue(Ext.getCmp("content2").getValue());            			
		        		}
						if(_form.isValid() && form.checkForm()){
							_form.submit({
					              url              : _form.url,
								  waitTitle        : '正在提交',
					              waitMsg          : '正在向服务器发送请求',
					              clientValidation : true,
								  success : function(form,action){
								  	if(action.result.success == true){
								  		if(action.result.keyFilter == true){
									  		Ext.Msg.show({
												title : '提示',
												msg : action.result.msg,
												buttons : {yes:'是', no:'否'},
												fn : function(btn){
												    if (btn == 'yes'){
												        _form.submit({
												       	  url              : 'admin/article/ArticleAction!addKeyFilterArticle'+_this.$config.exParams,
														  waitTitle        : '正在提交',
											              waitMsg          : '正在向服务器发送请求',
											              clientValidation : true,
														  success : function(form,action){
														  	if(action.result.success){
														  		_form.reset();
														  		channelName.setValue(tempChannelName);
																_this.$config.grid.store.reload();
														  	}
														  }
												        })
												   	}else{
												    	_form.submit({
												       	  url              : 'admin/article/ArticleAction!addArticleCommon'+_this.$config.exParams,
														  waitTitle        : '正在提交',
											              waitMsg          : '正在向服务器发送请求',
											              clientValidation : true,
														  success : function(form,action){
														  	if(action.result.success){
														  		_form.reset();
														  		channelName.setValue(tempChannelName);
																_this.$config.grid.store.reload();
														  	}
														  }
												        })
												   	}
												}
											});
								  		}else{
								  			_form.reset();
								  			channelName.setValue(tempChannelName);
											_this.$config.grid.store.reload();
								  		}
								  	}else{
								  		alertFailure(action.result);
								  	}
								  },
								  failure :function(form,action){
										if(action.failureType == Ext.form.Action.CLIENT_INVALID){
											Ext.Msg.alert('失败','输入的信息不符合规格，请按照提示重新输入！');
										}else{
											Ext.Msg.alert("失败",action.result.msg);
										}
								 }		
					        });
						  }
		        	}
			    }
				,{
		        	xtype   : 'submitbutton',
		        	text    : '保存并关闭',
		        	eventId : form.id,
		/*		    listeners  : {
						 beforeSubmit : function () {
							    if (Ext.getCmp("contentTab").getActiveTab().id == "panel_htmleditor") {
									Ext.getCmp("content").setValue(Ext.getCmp("content1").getValue());            			
			            		} else {
									Ext.getCmp("content").setValue(Ext.getCmp("content2").getValue());     
			            		}
							 	return form.checkForm();
						 },
						afterSubmit   : function(form,action) {
							_this.close();
							_this.$config.grid.store.reload();
								
						}
				   }            */	
		        	handler : function() {
		        		if (Ext.getCmp("contentTab").getActiveTab().id == "panel_htmleditor") {
							Ext.getCmp("content").setValue(Ext.getCmp("content1").getValue());            			
		        		} else {
							Ext.getCmp("content").setValue(Ext.getCmp("content2").getValue());            			
		        		}
						if(_form.isValid() && form.checkForm()){
							_form.submit({
					              url              : _form.url,
								  waitTitle        : '正在提交',
					              waitMsg          : '正在向服务器发送请求',
					              clientValidation : true,
								  success : function(form,action){
								  	if(action.result.success == true){
								  		if(action.result.keyFilter == true){
									  		Ext.Msg.show({
												title : '提示',
												msg : action.result.msg,
												buttons : {yes:'是', no:'否'},
												fn : function(btn){
												    if (btn == 'yes'){
												        _form.submit({
												       	  url              : 'admin/article/ArticleAction!addKeyFilterArticle'+_this.$config.exParams,
														  waitTitle        : '正在提交',
											              waitMsg          : '正在向服务器发送请求',
											              clientValidation : true,
														  success : function(form,action){
														  	if(action.result.success){
														  		_this.close();
																_this.$config.grid.store.reload();
														  	}
														  }
												        })
												   	}else{
												    	_form.submit({
												       	  url              : 'admin/article/ArticleAction!addArticleCommon'+_this.$config.exParams,
														  waitTitle        : '正在提交',
											              waitMsg          : '正在向服务器发送请求',
											              clientValidation : true,
														  success : function(form,action){
														  	if(action.result.success){
														  		_this.close();
																_this.$config.grid.store.reload();
														  	}
														  }
												        })
												   	}
												}
											});
								  		}else{
								  			_this.close();
											_this.$config.grid.store.reload();
								  		}
								  	}else{
								  		alertFailure(action.result);
								  	}
								  },
								  failure :function(form,action){
										if(action.failureType == Ext.form.Action.CLIENT_INVALID){
											Ext.Msg.alert('失败','输入的信息不符合规格，请按照提示重新输入！');
										}else{
											Ext.Msg.alert("失败",action.result.msg);
										}
								 }		
					        });
						  }
		        	}
			    }
			    ,{
		        	xtype:'button',
		        	text:'关闭',
		        	handler : function() {
		        		_this.close();	
		        	}            	
			    }]
			})
		}else{
			Ext.apply(thisConfig,{
				buttons : [
					{
		        	xtype   : 'submitbutton',
		        	text    : '保存并关闭',
		        	eventId : form.id,
		/*		    listeners  : {
						 beforeSubmit : function () {
							    if (Ext.getCmp("contentTab").getActiveTab().id == "panel_htmleditor") {
									Ext.getCmp("content").setValue(Ext.getCmp("content1").getValue());            			
			            		} else {
									Ext.getCmp("content").setValue(Ext.getCmp("content2").getValue());     
			            		}
							 	return form.checkForm();
						 },
						afterSubmit   : function(form,action) {
							_this.close();
							_this.$config.grid.store.reload();
								
						}
				   }            */	
		        	handler : function() {
		        		if (Ext.getCmp("contentTab").getActiveTab().id == "panel_htmleditor") {
							Ext.getCmp("content").setValue(Ext.getCmp("content1").getValue());            			
		        		} else {
							Ext.getCmp("content").setValue(Ext.getCmp("content2").getValue());            			
		        		}
						if(_form.isValid() && form.checkForm()){
							_form.submit({
					              url              : _form.url,
								  waitTitle        : '正在提交',
					              waitMsg          : '正在向服务器发送请求',
					              clientValidation : true,
								  success : function(form,action){
								  	if(action.result.success == true){
								  		if(action.result.keyFilter == true){
									  		Ext.Msg.show({
												title : '提示',
												msg : action.result.msg,
												buttons : {yes:'是', no:'否'},
												fn : function(btn){
												    if (btn == 'yes'){
												        _form.submit({
												       	  url              : 'admin/article/ArticleAction!editArticleFilterKey'+_this.$config.exParams,
														  waitTitle        : '正在提交',
											              waitMsg          : '正在向服务器发送请求',
											              clientValidation : true,
														  success : function(form,action){
														  	if(action.result.success){
														  		_this.close();
																_this.$config.grid.store.reload();
														  	}
														  }
												        })
												   	}else{
												    	_form.submit({
												       	  url              : 'admin/article/ArticleAction!editArticleCommon'+_this.$config.exParams,
														  waitTitle        : '正在提交',
											              waitMsg          : '正在向服务器发送请求',
											              clientValidation : true,
														  success : function(form,action){
														  	if(action.result.success){
														  		_this.close();
																_this.$config.grid.store.reload();
														  	}
														  }
												        })
												   	}
												}
											});
								  		}else{
								  			_this.close();
											_this.$config.grid.store.reload();
								  		}
								  	}else{
								  		alertFailure(action.result);
								  	}
								  },
								  failure :function(form,action){
										if(action.failureType == Ext.form.Action.CLIENT_INVALID){
											Ext.Msg.alert('失败','输入的信息不符合规格，请按照提示重新输入！');
										}else{
											Ext.Msg.alert("失败",action.result.msg);
										}
								 }		
					        });
						  }
		        	}
			    }
			    ,{
		        	xtype:'button',
		        	text:'关闭',
		        	handler : function() {
		        		_this.close();	
		        	}            	
			    }]
			})
		}
		
		
			
	}

	var _config = $config || {};
	Ext.apply(_this, Ext.apply(thisConfig, _config));
	VAS.ArticleContentWindow.superclass.constructor.call(_this);
};
Ext.extend(VAS.ArticleContentWindow,VAS.BasicWindow,{	

	loadForm:function(){
		var _this = this;
		
		
		this.items.itemAt(0).load({
			    waitTitle   : '正在加载中...',
				waitMsg     : '正在向服务器发送请求', 
	 			url         : this.$config.loadUrl,
	 			success     : function(form,action) {	
	 				
	 				if (action.result.data["authorizeState"] == 1) {
	 					Ext.getCmp("productCode").setDisabled(false);
	 				}
	 				var context = "article/ArticleAction";
 					if(_this.actionType == "articleArchiveEdit"){
 						context = "articlearchive/ArticleArchiveAction";
 					}
 					if(_this.actionType == "articleKeyFilterEdit"){
 						context = "keyfilter/KeyFilterAction";
 					}
	 				
	 				
	 				
	// 				Ext.getCmp("tiltePhoto").setValue("");
	 				var tiltePhotoName = action.result.data["tiltePhotoName"];
	 				var tiltePhotoDesc = Ext.getCmp("tiltePhotoDesc");
	 				if (tiltePhotoName != "" && tiltePhotoName != "null"  && tiltePhotoName != undefined &&_this.actionType != 'articlepreview') {
	 					tiltePhotoDesc.setValue("<font size='2' color='red'><a href=javascript:exportFile('admin/" + context + "!exportFile.action?id='+Ext.getCmp('id').getValue()+'&type=titlephoto')>"+tiltePhotoName+"</a>&nbsp;&nbsp;&nbsp;&nbsp;" +
	 							"<a href=# onclick= deleteFile('tiltePhoto','tiltePhotoDesc','titleflag'); >删除</a></font>");
	 				}else if(tiltePhotoName != "" && tiltePhotoName != "null"  && tiltePhotoName != undefined &&_this.actionType == 'articlepreview'){
	 					tiltePhotoDesc.setValue("<font size='2' color='red'><a href=javascript:exportFile('admin/article/ArticleAction!exportFile.action?id='+Ext.getCmp('id').getValue()+'&type=titlephoto')>"+tiltePhotoName+"</a>");
	 				}
	 				
	// 				Ext.getCmp("contentPhoto").setValue("");
	 				var contentPhotoName = action.result.data["contentPhotoName"];
	 				var contentPhotoDesc = Ext.getCmp("contentPhotoDesc");
	 				if (contentPhotoName != "" && contentPhotoName != "null"  && contentPhotoName != undefined &&_this.actionType != 'articlepreview') {
	 					contentPhotoDesc.setValue("<font size='2' color='red'><a href=javascript:exportFile('admin/" + context + "!exportFile.action?id='+Ext.getCmp('id').getValue()+'&type=contentphoto')>"+contentPhotoName+"</a>&nbsp;&nbsp;&nbsp;&nbsp;" +
	 							"<a href=# onclick= deleteFile('contentPhoto','contentPhotoDesc','contentflag');>删除</a></font>");	 					
	 				}else if(contentPhotoName != "" && contentPhotoName != "null"  && contentPhotoName != undefined &&_this.actionType == 'articlepreview'){
	 					contentPhotoDesc.setValue("<font size='2' color='red'><a href=javascript:exportFile('admin/article/ArticleAction!exportFile.action?id='+Ext.getCmp('id').getValue()+'&type=contentphoto')>"+contentPhotoName+"</a>");
	 				}
	 				
	// 				Ext.getCmp("audio").setValue("");
	 				var audioName = action.result.data["audioName"];
	 				var audioDesc = Ext.getCmp("audioDesc");
	 				if (audioName != "" && audioName != "null"  && audioName != undefined &&_this.actionType != 'articlepreview') {
	 					audioDesc.setValue("<font size='2' color='red'><a href=javascript:exportFile('admin/" + context + "!exportFile.action?id='+Ext.getCmp('id').getValue()+'&type=audio')>"+audioName+"</a>&nbsp;&nbsp;&nbsp;&nbsp;" +
	 							"<a href=# onclick= deleteFile('audio','audioDesc','audioflag'); >删除</a></font>");	 					
	 				}else if(audioName != "" && audioName != "null"  && audioName != undefined &&_this.actionType == 'articlepreview'){
	 					audioDesc.setValue("<font size='2' color='red'><a href=javascript:exportFile('admin/article/ArticleAction!exportFile.action?id='+Ext.getCmp('id').getValue()+'&type=audio')>"+audioName+"</a>");
	 				}
	 				
	 				var content = action.result.data["content"];
	 				var contentTab  = Ext.getCmp("contentTab");
	 				var pattern = /<\/?[^>]+>|&[^;]*;/gi;
	 				if (!pattern.test(content)) {
	 					contentTab.setActiveTab(1);
	 					Ext.getCmp("content2").setValue(content);
	 				} else {
	 					contentTab.setActiveTab(0);
	 					Ext.getCmp("content1").setValue(content);
	 				}
	 				
	 				if (action.result.data["isCommend"] == 1) {
	 					Ext.getCmp("isCommend1").setValue(action.result.data["isCommend"]);
	 				}
	 				if( _this.actionType == 'articlepreview'){
		 				Ext.getCmp("author").setDisabled(true);
		 				Ext.getCmp("isCommend1").setDisabled(true);
		 				Ext.getCmp("authorizeState").setDisabled(true);
		 				Ext.getCmp("title").setDisabled(true);
		 				Ext.getCmp("origin").setDisabled(true);
		 				Ext.getCmp("videoCode").setDisabled(true);
		 				Ext.getCmp("productCode").setDisabled(true);
		 				Ext.getCmp("sdUrl").setDisabled(true);
		 				Ext.getCmp("hdUrl").setDisabled(true);
		 				Ext.getCmp("tiltePhoto").setDisabled(true);
		 				Ext.getCmp("contentPhoto").setDisabled(true);
		 				Ext.getCmp("audio").setDisabled(true);
		 				Ext.getCmp("contentHDTemplate").setDisabled(true);
		 				Ext.getCmp("contentSDTemplate").setDisabled(true);
		 				Ext.getCmp("keyword").setDisabled(true);
		 				Ext.getCmp("content1").setDisabled(true);
		 				Ext.getCmp("content2").setDisabled(true);
	 				}
	 			},
	 			failure     : function(form,action) {
	 				Ext.Msg.alert("失败",action.result.msg);
	 			},
	 			params      : {
	 				data    : Ext.util.JSON.encode(this.$config.postData)
	 			}
	 	});			
	}
});

Ext.reg('articlecontent-win',VAS.ArticleContentWindow);





